<?php
 defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.model' );
class ThoikhoabieuModelTKB extends JModel{
	var $_listTKB =null;
	var $listnganh =null;

		
		function getTkbMonhoc(){
				if(!$this->_listTKB){
					$query = "SELECT * FROM #__thoikhoabieu tkb join #__monhoc mh on(tkb.f_mamh=mh.f_mamh) left join #__canbo  cb on(cb.f_manv=tkb.f_manv) order by tkb.f_mamh,tkb.f_manh,tkb.f_thu asc";
				 	//$db =& JFactory::getDBO();
					 $this->_db->setQuery($query);
      				 $this->_listTKB = $this->_getList($query, 0, 0);
					 if (empty( $this->_listTKB )) {
      					return JError::raiseWarning( 500, JText::_( 'Empty table' ) );
   					}
				}
				return $this->_listTKB;
		}	
		
		function getListNganh(){
			$db =& JFactory::getDBO();
			//$he=JRequest::getVar('he');
			//$query = "SELECT * FROM #__lop where F_MAHE='".$he."'";
			$query = "SELECT * FROM #__lop where F_MAHE='DH";
			$db->setQuery( $query, 0);
			$this->listnganh = array();
			if($rows = $db->loadObjectList()) {
				foreach ($rows as $row)
				{
					// Encode text to HTML formatting
					$manganh = htmlspecialchars($row->F_MANGANH, ENT_QUOTES);
					$nganh = htmlspecialchars($row->F_NGANH, ENT_QUOTES);
					$this->listnganh[$manganh] =$nganh;
				}
			}
			return $this->listnganh;
		}
	
}